<template>
  <div class="listl">
    <ul class="details">
      <p>云音乐特色榜</p>

      <li v-for="(item, index) in listArr" :key="index" @click="Go(item)" :class="{ active: item.id == id }">
        <img :src="item.coverImgUrl" alt="" width="40" height="40" />
        <div class="right">
          <span>{{ item.name }}</span>
          <span>{{ item.updateFrequency }}</span>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import { BdApi } from "@/request/api";
export default {
  data() {
    return {
      listArr: "",
    };
  },
  created() {
    BdApi().then((res) => {
      console.log(res);
      this.listArr = res.data.list;
    });
  },
  methods: {
    Go(item) {
      this.$router.push({
        path: "/list",
        query: {
          id: item.id,
        },
      });
    },
  },
   computed: {
    id() {
      if (this.$route.query.id == undefined) return "19723756";
      return this.$route.query.id;
    },
  },
};
</script>
 
<style lang = "less" scoped>
@import "../../assets/base";
.listl {
  width: 240px;
  background-color: #eee;
  border: 1px solid #ccc;
  p {
    margin-top: 30px;
    font-size: 24px;
    line-height: 60px;
    height: 60px;
    margin-left: 20px;
    /* background-color: pink; */
  }
  li {
    height: 60px;
    /* background-color: plum; */
    line-height: 30px;
    padding: 10px;
    box-sizing: border-box;
    span {
      margin-left: 20px;
      font-size: 12px;
    }
    img {
      vertical-align: middle;
      margin-left: 10px;
    }
    .right {
      margin-left: 50px;
      margin-top: -55px;
      span {
        display: block;
        height: 20px;
        line-height: 50px;
      }
    }
  }
   .active {
    background: rgb(230, 230, 230);
  }
}
</style>